package com.spzx.product.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.product.api.domain.vo.CategoryVo;
import com.spzx.product.api.service.RemoteCategoryService;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;


import java.util.List;

@Component
public class RemoteCategoryFallbackFactory implements FallbackFactory<RemoteCategoryService> {


    @Override
    public RemoteCategoryService create(Throwable cause) {
        return new RemoteCategoryService() {
            @Override
            public R<List<CategoryVo>> getFirstLeveCategory(Long parentId, String source) {
                return R.fail("远程调用商品微服务获取分类信息失败"+cause.getMessage());
            }

            @Override
            public R<List<CategoryVo>> getCategoryTreeList(String source) {
                return R.fail("远程调用商品微服务获取分类树失败"+cause.getMessage());
            }
        };
    }
}

